package com.ruoyi.project.system.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.web.domain.BaseEntity;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

import static com.ruoyi.common.utils.uuid.Seq.getPayOrderNo;

/**
 * 支付对象 sm_pay
 */
@Data
public class SmPay extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    private Integer id;

    /**
     * 类型
     */
    @Excel(name = "类型")
    private String type;

    /**
     * 用户ID
     */
    @Excel(name = "用户ID")
    private Long userId;

    /**
     * 外部单号
     */
    @Excel(name = "外部单号")
    private Integer outId;

    /**
     * 系统支付单号
     */
    @Excel(name = "系统支付单号")
    private String orderNo;

    /**
     * 商品标题
     */
    @Excel(name = "商品标题")
    private String subject;

    /**
     * 请求支付金额
     */
    @Excel(name = "请求支付金额")
    private BigDecimal pricing;

    /**
     * 实际支付金额
     */
    @Excel(name = "实际支付金额")
    private BigDecimal actualPayAmount;

    /**
     * 支付平台生订单号
     */
    @Excel(name = "支付平台生订单号")
    private String platformOrderNo;

    /**
     * 支付方式
     */
    @Excel(name = "支付方式")
    private String payType;

    /**
     * 支付状态
     */
    @Excel(name = "支付状态")
    private String payState;

    /**
     * 付款时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "付款时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date payTime;

    /**
     * 删除标志
     */
    @Excel(name = "删除标志")
    private String delSign;

    public SmPay() {
    }

    public SmPay(Integer id, String payState) {
        this.id = id;
        this.payState = payState;
    }

    public SmPay(SmQuery smQuery, String type, BigDecimal pricing, String subject) {
        this.userId = smQuery.getUserId();
        this.outId = smQuery.getId();
        this.payType = smQuery.getRemark();
        this.pricing = pricing;
        this.type = type;
        this.orderNo = getPayOrderNo();
        this.subject = subject;
    }

    public SmPay(BigDecimal pricing, String subject, Long userId, String payType, String remark) {
        this.pricing = pricing;
        this.subject = subject;
        this.userId = userId;
        this.payType = payType;
        this.setRemark(remark);
        this.type = "upgrade";
        this.orderNo = getPayOrderNo();
    }

    public SmPay(Integer id, BigDecimal actualPayAmount, String platformOrderNo, String payState, Date payTime) {
        this.id = id;
        this.actualPayAmount = actualPayAmount;
        this.platformOrderNo = platformOrderNo;
        this.payState = payState;
        this.payTime = payTime;
    }

}
